#!/usr/bin/env bash
set -e

echo "[setup] 更新系统包索引..."
sudo apt-get update -y

echo "[setup] 安装系统依赖 (OpenCV 运行库、语音、编解码)..."
sudo apt-get install -y \
  python3-pip \
  python3-opencv \
  espeak \
  ffmpeg \
  libatlas-base-dev

echo "[setup] 升级 pip..."
python3 -m pip install --upgrade pip

echo "[setup] 安装 Python 依赖...（若 torch 安装失败请参考 README）"
python3 -m pip install -r requirements-pi.txt || {
  echo "[warn] 一些依赖安装失败（可能是 torch/torchvision）。请参考 README 获取适配 wheel。"
}

echo "[setup] 完成。"